//
//  LRQTrueAttributeVC.m
//  1. __attribute__()
//
//  Created by lirenqiang on 2016/11/2.
//  Copyright © 2016年 1111. All rights reserved.
//

#import "LRQTrueAttributeVC.h"
#define kMaxStringLen 512

extern void MyLog(const char *tag, const char *format, ...) __attribute__((format(printf, 2, 3)));

extern int square(int i) __attribute__((warn_unused_result));

extern void noreturn(void) __attribute__((noreturn));

@interface LRQTrueAttributeVC ()

@end

@implementation LRQTrueAttributeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    MyLog("123","%zd", 10);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

void MyLog(const char *tag, const char *format, ...)
{
    va_list ap;
    va_start(ap, format);
    
    char *pBuf = (char *)malloc(kMaxStringLen);
    if (pBuf != NULL) {
        vsnprintf(pBuf, kMaxStringLen, format, ap);
    }
    va_end(ap);
    
    printf("TAG: %s Message: %s", tag, pBuf);
    free(pBuf);
    
    char* str __attribute__((cleanup(helloworld))) = "123";
    
}



int square(int i)
{
    return i*i;
}

void helloworld(char **str)
{
    printf("%s hello world!\n", *str);
}




@end
